package com.msh.artascope.devcloud.client.po;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.msh.artascope.interfaces.ILoginAccount;
import com.msh.frame.client.base.BasePo;
import com.msh.frame.client.validation.IDeleteVo;
import com.msh.frame.client.validation.IInsertVo;
import com.msh.frame.client.validation.IUpdateVo;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.Date;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;

/**
 * @author shihu
 * @email m-sh@qq.com
 */
@Data
@Accessors(chain = true)
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Schema(title = "域名配置Po")
public class DomainConfigPo extends BasePo {
  /**
   * 主键id
   */
  @NotNull(groups = {IUpdateVo.class, IDeleteVo.class}, message = "id不能为空")
  @Schema(title = "主键id")
  private Long id;

  /**
   * 域名
   */
  @NotNull(groups = {IInsertVo.class}, message = "域名不能为空")
  @Size(groups = {IUpdateVo.class, IInsertVo.class}, max = 50, message = "domain长度范围最大50")
  @Schema(title = "域名")
  private String domain;

  /**
   * http协议
   */
  @NotNull(groups = {IInsertVo.class, IUpdateVo.class}, message = "http协议不能为空")
  @Schema(title = "http协议")
  private Integer httpFlag;

  /**
   * https协议
   */
  @NotNull(groups = {IInsertVo.class, IUpdateVo.class}, message = "https协议不能为空")
  @Schema(title = "https协议")
  private Integer httpsFlag;

  /**
   * 证书
   */
  @Size(groups = {IUpdateVo.class, IInsertVo.class}, max = 20, message = "tslCert长度范围最大20")
  @Schema(title = "证书")
  private String tslCert;

  /**
   * 环境
   */
  @NotNull(groups = {IInsertVo.class}, message = "环境不能为空")
  @Schema(title = "环境")
  private Long envId;

  /**
   * 租户id
   */
  @Schema(title = "租户id")
  private Long tenantId;

  /**
   * 更新版本
   */
  @NotNull(groups = {IUpdateVo.class}, message = "更新版本不能为空")
  @Schema(title = "更新版本")
  private Integer updateVersion;

  /**
   * 创建时间
   */
  @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
  @Schema(title = "创建时间")
  private Date createTime;

  /**
   * 更新时间
   */
  @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
  @Schema(title = "更新时间")
  private Date updateTime;


  public void initLoginAccount(ILoginAccount loginAccount) {
    this.tenantId = loginAccount.getTenantId();
  }
}



